<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
	span{
		font-weight: bold;
	}
</style>
<script src="js/jquery-1.12.4.js"></script>
<script type="text/javascript">
$(function(){
	
	$("#id").blur(function(){
		var id = $("#id").val(); //获取用户输入的产品代码
		//使用ajax ,去后台servlet中验证 产品代码是否存在
		//$.getJSON("url","param",回调函数);
		$.getJSON("CheckFinProServlet","pid="+id ,function(data){
			
			if(data.msg ==1){
				//存在,不可用
				$("#spanId").html("代码不可用");
			}else{
				//不存在,可以用	
				$("#spanId").html("代码可用");
			}
		});
	});
})
</script>
</head>
<body>
	<form action="AddFinProServlet" id="myform">
		<h1>新增理财信息</h1>
			<span>产品代码</span><input type="text" name="id" id="id"/><span id="spanId"></span><br/>
			<span>风险评级</span><select name="risk" id="risk">
				<option value="-1">--请选择--</option>
				<option value="1">R1</option>
				<option value="2">R2</option>
				<option value="3">R3</option>
			</select><br/>
			<span>预期收益</span> <input type="text" name="income" id="income"/><br/>
			<span>发售起始日</span> <input type="text" name="saleStarting" id="saleStarting" /><br/>
			<span>发售截止日</span> <input type="text" name="saleEnd" id="saleEnd" /><br/>
			<span>产品到期日</span> <input type="text" name="end" id="end"/><br/>
			<input type="submit" value="保存" />
			<input type="button" value="返回" onclick="history.back()" />
		</form>
</body>
</html>